Skip to content

Fix WP genotype condition always evaluating to False in vcf_func.py - #261

Merged
joshfactorial merged 2 commits into
developfrom
fix/vcf-wp-genotype-condition
Apr 7, 2026
Merged

Fix WP genotype condition always evaluating to False in vcf_func.py#261
joshfactorial merged 2 commits into
developfrom
fix/vcf-wp-genotype-condition

Conversation

@joshfactorial

Copy link
Copy Markdown
Collaborator

The condition checked if the string "WP" was a member of a list of lists ([x.split('=') for x in ...]), which can never be True. The fix extracts only the key portion of each INFO field pair ([x.split('=')[0] for x in ...]) so the membership test works as intended for legacy NEAT WP genotype records.

joshfactorial and others added 2 commits April 4, 2026 19:49
The condition checked if the string "WP" was a member of a list of lists
([x.split('=') for x in ...]), which can never be True. The fix extracts
only the key portion of each INFO field pair ([x.split('=')[0] for x in ...])
so the membership test works as intended for legacy NEAT WP genotype records.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tests

Both WP code paths used 'for record in record[7].split(";")' which shadowed
the outer record list, causing a crash at the chrom/location assignments
that follow. Fixed by renaming the loop variable to info_item and, in the
has-format path, capturing record[9] before the loop begins.

Also adds tests/test_read_simulator/test_vcf_func.py with 14 tests covering:
  - Path B (no FORMAT, WP in INFO): genotype matches WP value, slash/pipe
    notation, WP among other fields, WP absent → random genotype
  - Path A (FORMAT without GT, WP in INFO): genotype from WP
  - Standard GT path: unaffected by WP fix
  - General correctness: unknown chrom skipped, ref mismatch skipped,
    missing QUAL defaulted

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@joshfactorial
joshfactorial merged commit 4f09fbe into develop Apr 7, 2026
1 check passed
@joshfactorial
joshfactorial deleted the fix/vcf-wp-genotype-condition branch April 18, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant